/*
 * @Author: 胡海
 * @Date: 2020-02-10 19:39:49
 * @LastEditors: 胡海
 * @LastEditTime: 2020-03-08 15:32:07
 * @Description: 
 */
const Router = require('koa-router')
const {
    Auth
} = require('../../../middlewares/auth')
const {
    addFundValidator,
    listFundValidator,
    editFundValidator
} = require('../../validators/fund')
const {
    PositiveIdValidator
} = require('../../validators/common')

const {
    Fund
} = require('../../models/fund')

const router = new Router({
    prefix: '/v1/fund'
})

router.post('/addFund', new Auth().m, async (ctx) => { // 新增
    const v = await new addFundValidator().validate(ctx)
    const data = await Fund.addFund(ctx, v)
})
router.post('/editFund', new Auth().m, async (ctx) => { // 修改
    const v = await new editFundValidator().validate(ctx)
    const data = await Fund.editFund(ctx, v)
})
router.post('/delFund', new Auth().m, async (ctx) => { // 删除
    const v = await new PositiveIdValidator().validate(ctx)
    const data = await Fund.delFund(ctx, v)
})
router.post('/listFund', new Auth().m, async (ctx) => { // 列表
    const v = await new listFundValidator().validate(ctx)
    // const data = await Fund.listFund(ctx, v)
    ctx.body = {
        error_code: 0,
        msg: 'ok',
        data:"huhai"
    }
})

module.exports = router